﻿using AutoMapper;
using B.S.Filtration.Domain.到货检验;
using B.S.Filtration.ErrorCode;
using B.S.Filtration.Read.Api.Application.Command.到货检验.QualityLnspectionCommand;
using MediatR;
using SqlSugar;

namespace B.S.Filtration.Read.Api.Application.CommandHander.到货检验.QualityLnspectionHandler
{
    public class FTQualityLnspectionHandler : IRequestHandler<FTQualityLnspectionCommand, APIResult<List<QualityLnspection>>>
    {
        private readonly ISqlSugarClient db;
        private readonly IMapper mapper;
        public FTQualityLnspectionHandler(ISqlSugarClient db, IMapper mapper)
        {
            this.db = db;
            this.mapper = mapper;
        }
        public async Task<APIResult<List<QualityLnspection>>> Handle(FTQualityLnspectionCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<QualityLnspection>> result = new APIResult<List<QualityLnspection>>();
            var list = await db.Queryable<QualityLnspection>().Where(x => x.IsDel == false && x.Qualityid == request.Qualityid).ToListAsync();
            result.data = list;
            result.code = APIResultCode.success;
            result.msg = "显示成功";
            return await Task.FromResult(result);
        }
    }
}
